
#ifndef _ZMQCLIENT_H_
#define _ZMQCLIENT_H_

#include "channel.h"
#include <map>
#include <time.h>
#include "rf/event/RFEventManager.h"
#include "rf/event/RFTimerFired.h"
#include "rf/event/rooftop_event.h"

using namespace ProcessRouter;

class ZmqMessageHandle: public ChannelHandle {
    public:
        ZmqMessageHandle();
        ~ZmqMessageHandle();

        virtual void didRecevied();
        virtual void didConnected();
        virtual void didError();

        bool onRequest(Rooftop::EventBase &e);
        bool onAnwser(Rooftop::EventBase &e);
        bool onChildProcessError(Rooftop::EventBase &e);
        bool onGetFreePid(Rooftop::EventBase &e);
        bool onReleasePid(Rooftop::EventBase &e);

        bool hasCpidRequest(int cpid);
        void doExit();

        int connectSize();

    private:
        std::map<std::string, CMessage> m_addressMap;
        std::map<std::string, int> m_cpidMap;
        std::map<std::string, int> m_caimpidMap;
        std::map<int, time_t> m_caimpidTimeMap;
        int m_connectSize;
};

#endif

